package com.gxa.service.discrepancy.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gxa.entity.discrepancy.Track;
import com.gxa.entity.discrepancy.VisitorList;
import com.gxa.entity.discrepancy.search.TrackSearchMap;
import com.gxa.entity.discrepancy.search.VisitorSearchMap;
import com.gxa.service.discrepancy.VisitorListService;
import com.gxa.mapper.discrepancy.VisitorListMapper;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author Administrator
* @description 针对表【visitor_list(访客列表)】的数据库操作Service实现
* @createDate 2022-10-14 11:27:00
*/
@Service
public class VisitorListServiceImpl extends ServiceImpl<VisitorListMapper, VisitorList>
    implements VisitorListService{

    @Autowired
    private VisitorListMapper mapper;
    @Override
    public PageInfo<VisitorList> queryByPage(VisitorSearchMap map) {
        PageHelper.startPage(map.getPageNum(),map.getPageSize());//1.开启分页

        QueryWrapper<VisitorList> wrapper = new QueryWrapper<>();//2.条件构造器 模拟写动态sql  或者在xml 中写
        if (!StringUtils.isAnyBlank(map.getName())) {
            wrapper.like("visitor_name", map.getName());
        }

        if(!StringUtils.isAnyBlank(map.getPhone())){
            wrapper.like("phone",map.getPhone());
        }
        if(!StringUtils.isAnyBlank(map.getCarNum())){
            wrapper.like("car_num",map.getCarNum());
        }
        if(!StringUtils.isAnyBlank(map.getStartTime(),map.getEndTime())){
            wrapper.between("recent_pass_time",map.getStartTime(),map.getEndTime());
        }
        PageInfo<VisitorList> pageInfo = new PageInfo<>(mapper.selectList(wrapper));//3.获取分页信息
        return pageInfo;
    }
}




